import request from '@/utils/request';

/**
 * @Date         : 2023-03-14 22:37:17
 * @description  : 获取一级分类
 * @return        {*}
 */
export const getCategoryFirst = () => {
	return request({
		url: '/admin/product/getCategory1',
		method: 'get',
	});
};

/**
 * @Date         : 2023-03-14 23:24:12
 * @description  : 二级分类
 * @param         {*} id:
 * @return        {*}
 */
export const getCategoryTwo = category1Id => {
	return request({
		url: `/admin/product/getCategory2/${category1Id}`,
		method: 'get',
	});
};

/**
 * @Date         : 2023-03-14 23:36:46
 * @description  : 三级
 * @param         {*} category2Id:
 * @return        {*}
 */
export const getCategoryThree = category2Id => {
	return request({
		url: `/admin/product/getCategory3/${category2Id}`,
		method: 'get',
	});
};

/**
 * @Date         : 2023-03-14 23:46:37
 * @description  : 获取商品基础属性
 * @param         {*} category1Id:
 * @param         {*} category2Id:
 * @param         {*} category3Id:
 * @return        {*}
 */
export const getAttrInfoList = (category1Id, category2Id, category3Id) => {
	return request({
		url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
		method: 'get',
	});
};

/**
 * @Date         : 2023-03-15 14:15:03
 * @description  : 保存修改后的属性
 * @param         {*} data:
 * @return        {*}
 */
export const saveAttrInfo = data => {
	return request({
		url: '/admin/product/saveAttrInfo',
		method: 'post',
		data,
	});
};

/**
 * @Date         : 2023-03-15 16:04:21
 * @description  : 删除属性
 * @param         {*} attrId:
 * @return        {*}
 */
export const deleteAttr = attrId => {
	return request({
		url: `/admin/product/deleteAttr/${attrId}`,
		method: 'delete',
	});
};
